//
//  DialerItem.m
//  LabanBrowser
//
//  Created by -Xh- on 3/13/13.
//  Copyright (c) 2013 VNG. All rights reserved.
//

#import "DialerItem.h"

@implementation DialerItem
@synthesize titleLabel;
@synthesize url;
@synthesize delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        // Initialization code
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"DialerItem" owner:self options:nil];
        
        if ([arrayOfViews count] < 1) {
            return nil;
        }
        
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
            return nil;
        }
        
        self = [arrayOfViews objectAtIndex:0];
        
        //[self.thumbImage.layer setMasksToBounds:YES];
        [self.thumbImage.layer setCornerRadius:5.0];
        
        // You can even add a border
        [self.thumbImage.layer setBorderWidth:1.5];
        self.thumbImage.layer.borderColor=[[UIColor lightGrayColor]CGColor];
        
                
    }
    
    return self;
}

-(void)needToShowBorder:(BOOL)_need{
    if(_need){
        [self.thumbImage.layer setBorderWidth:1.5];
    }else{
        [self.thumbImage.layer setBorderWidth:0];
    }
}
-(void)needToHighlight:(BOOL)_need{

    if(_need){
        [self.thumbImage.layer setBorderWidth:1.5];
        self.thumbImage.layer.borderColor=[[UIColor blackColor]CGColor];
        
    }else{
        [self.thumbImage.layer setBorderWidth:1.5];
        self.thumbImage.layer.borderColor=[[UIColor lightGrayColor]CGColor];
    }
    [self needToHighlightTextOnly:_need];
}
-(void)needToHighlightTextOnly:(BOOL)_need{
    CGFloat fontSize = self.titleLabel.font.pointSize;
    if(_need){
        
        
        self.titleLabel.font=[UIFont boldSystemFontOfSize:fontSize];
        self.titleLabel.textColor=[UIColor blackColor];
    }else{

        self.titleLabel.font=[UIFont systemFontOfSize:fontSize];
        self.titleLabel.textColor=[UIColor blackColor];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (IBAction)onDial:(id)sender {
    if(delegate && [delegate respondsToSelector:@selector(onDialAtURL:)]){
        [delegate onDialAtURL:self.url];
    }
}
@end
